home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 12 / Cream of the Crop 12 (Part II) / Cream of the Crop 12 (Part II).iso / OS2 / HELLO.ZIP / os2 / JCCALJUL.CMD < prev    next >
Encoding:
Text File  |  1996-04-02  |  3.8 KB  |  91 lines

  1. /******************************* REXX *********************************/
  2. /*        REXX Function to calculate and return Julian Dates          */
  3. /*  This is a port of an ANSI COBOL program which calculated Julian   */
  4. /*  dates based on passed Gregorian dates.  The original program and  */
  5. /*  REXX port were both done by Jaime A. Cruz, Jr.  This program is   */
  6. /*  released to the public domain.  You may contact the author at     */
  7. /*  72267.1372@compuserve.com, or jcruz@ibm.net                       */
  8. /**********************************************************************/
  9. /*                   Table of days in each month.                     */
  10. /**********************************************************************/
  11. month.0 = 12
  12. month.1 = 31
  13. month.2 = 28
  14. month.3 = 31
  15. month.4 = 30
  16. month.5 = 31
  17. month.6 = 30
  18. month.7 = 31
  19. month.8 = 31
  20. month.9 = 30
  21. month.10 = 31
  22. month.11 = 30
  23. month.12 = 31
  24.  
  25. /**********************************************************************/
  26. /*     Argument passed must be in mm/dd/yy or mm/dd/yyyy format.      */
  27. /**********************************************************************/
  28. Parse Upper Arg greg_date, .
  29. Select
  30. /**********************************************************************/
  31. /*  If a two digit year was passed, extract the century from the      */
  32. /*  system, and set a flag indicating the short form was used         */
  33. /**********************************************************************/
  34.    When Length(greg_date) = 8 Then
  35.       Do
  36.          Parse Value greg_date With 1 greg_month 3 ,
  37.                                     4 greg_day 6 ,
  38.                                     7 greg_year 9
  39.          greg_cent = Left(Date('S'), 2)
  40.          short = 1
  41.       End
  42. /**********************************************************************/
  43. /*  If a four digit year was passed, use the century the user         */
  44. /*  specified.  Set a flag indicating the long form was used.         */
  45. /**********************************************************************/
  46.    When Length(greg_date) = 10 Then
  47.       Do
  48.          Parse Value greg_date With 1 greg_month 3 ,
  49.                                     4 greg_day 6 ,
  50.                                     7 greg_cent 9 ,
  51.                                     9 greg_year 11
  52.          short = 0
  53.       End
  54. /**********************************************************************/
  55. /*  If an unrecognized date was passed, we'll default to today's      */
  56. /*  date in the long form.                                            */
  57. /**********************************************************************/
  58.    Otherwise
  59.       Do
  60.          Parse Value Date('S') With 1 greg_cent 3 ,
  61.                                     3 greg_year 5 ,
  62.                                     5 greg_month 7 ,
  63.                                     7 greg_day 9
  64.          short = 0
  65.       End
  66. End
  67.  
  68. If JCLepYer(greg_cent || greg_year) Then
  69.    month.2 = 29
  70.  
  71. /**********************************************************************/
  72. /*                     Calculate the Julian Date                      */
  73. /**********************************************************************/
  74. jul_date = greg_year * 1000
  75. Do x = 1 To (greg_month - 1)
  76.    jul_date = jul_date + month.x
  77. End
  78. jul_date = jul_date + greg_day
  79. jul_date = Right(jul_date, 5, '0')
  80.  
  81. /**********************************************************************/
  82. /*       If the long form was requested, include the century.         */
  83. /**********************************************************************/
  84. If \ short Then
  85.    jul_date = greg_cent || jul_date
  86.  
  87. /**********************************************************************/
  88. /*         Return the calculated Julian date to the invoker.          */
  89. /**********************************************************************/
  90. Return jul_date
  91.